package com.ruoyi.framework.web.service;

import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.core.domain.model.LoginBody;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

/**
 * @Author: Zhihj
 * @Date: 2023-04-03 21:21:35
 */
@Component
public class SysLoginService {
    @Autowired
    private RedisTemplate redisTemplate;

    /**
     * 登录验证
     * @param loginBody 登录方法体
     * @return
     */
    public String login(LoginBody loginBody){

        String username = loginBody.getUsername();
        String password = loginBody.getPassword();
        String code = loginBody.getCode();
        String uuid = loginBody.getUuid();
        //1.校验验证码
        validateCaptcha(username,code,uuid);


        return null;
    }

    /**
     * 校验验证码是否正确
     * @param username
     * @param code
     * @param uuid
     */
    private void validateCaptcha(String username, String code, String uuid) {

        //获取验证码开关
        String captchaEnabled = (String)redisTemplate.opsForValue().get(CacheConstants.SYS_CONFIG_KEY +"sys.account.captchaEnabled");
    }
}
